﻿using DFGK.IService;
using DFGK_WMS.Common;
using DFGK_WMS.Model.Dto;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using System.Security.Cryptography;

namespace DFGK_WMS.WebAPI.Controllers.PDA.移库管理
{
    /// <summary>
    /// 移库管理
    /// </summary>
    [Route("api/[controller]/[action]")]
    [ApiController]
    [ApiExplorerSettings(GroupName = "PDA")]
    public class TransferBinOrdersController : BaseController
    {
        private readonly ITransferBinOrderService transferBinOrderService;
        /// <summary>
        /// 
        /// </summary>
        /// <param name="environment"></param>
        /// <param name="transferBinOrderService"></param>
        public TransferBinOrdersController(IWebHostEnvironment environment, ITransferBinOrderService transferBinOrderService) : base(environment)
        {
            this.transferBinOrderService = transferBinOrderService;
        }

        /// <summary>
        /// 开始移库
        /// </summary>
        /// <param name="m"></param>
        /// <returns></returns>
        [HttpPost]
        public IActionResult StartTransferBinOrder(TransferBinOrderDTO m)
        {
            if (m.Id <= 0)
            {
                return Ok(BaseResult.Result("400", "Id有误！"));
            }
            m.NowUserId = base.BaseGetNowUserId();
            m.NowUserName = base.BaseGetNowUserName();
            bool result = transferBinOrderService.StartTransferBinOrder(m, out string message);
            if(result)
                return Ok(BaseResult.Result(true, "操作成功！", "200"));
            return Ok(BaseResult.Result(false, "操作失败！"+message, "500"));
        }
    }
}
